const router = require("express").Router();

const user = require("../api/user");
const product = require("../api/product");
const address = require("../api/address");
const category = require("../api/category");
const shoppcart = require("../api/cart");
const employee = require("../api/employee");
const brand = require("../api/brand");

// router.get("/test", (req, res) => { res.send("test router") });

// category router list
router.get("/queryTopCategory", category.queryTopCategory);
router.get("/querySecondCategory", category.querySecondCategory);
router.get("/queryTopCategoryPaging", category.checkRootLogin);
router.get("/queryTopCategoryPaging", category.queryTopCategoryPaging);
router.post("/updateTopCategory", category.checkRootLogin);
router.post("/updateTopCategory", category.updateTopCategory);
router.post("/addTopCategory", category.checkRootLogin);
router.post("/addTopCategory", category.addTopCategory);
router.get("/querySecondCategoryPaging", category.checkRootLogin);
router.get("/querySecondCategoryPaging", category.querySecondCategoryPaging);
router.post("/addSecondCategoryPic", category.checkRootLogin);
router.post("/addSecondCategoryPic", category.addSecondCategoryPic);

router.post("/updateSecondCategory", brand.checkRootLogin);
router.post("/updateSecondCategory", brand.updateSecondCategory);
router.post("/addSecondCategory", brand.checkRootLogin);
router.post("/addSecondCategory", brand.addSecondCategory);


// user router list
router.post("/register", user.register);
router.post("/login", user.login);
router.get("/logout", user.logout);
router.post("/updatePassword", user.checkUserLogin);
router.post("/updatePassword", user.updatePassword);
router.get("/queryUserMessage", user.checkUserLogin);
router.get("/queryUserMessage", user.queryUserMessage);
router.get("/vCode", user.vCode);
router.get("/vCodeForUpdatePassword", user.vCodeForUpdatePassword);
router.get("/queryUser", user.queryUser);
router.post("/updateUser", user.checkRootLogin);
router.post("/updateUser", user.updateUser);

// product router list
router.get("/queryProduct", product.queryProduct);
router.get("/queryProductDetail", product.queryProductDetail);
router.get("/queryProductDetailList", product.checkRootLogin);
router.get("/queryProductDetailList", product.queryProductDetailList);
router.post("/addProductPic", product.addProductPic);
router.post("/addProduct", product.checkRootLogin);
router.post("/addProduct", product.addProduct);
router.post("/updateProduct", product.updateProduct);

// address router list
router.post("/addAddress", address.checkUserLogin);
router.post("/addAddress", address.addAddress);
router.post("/updateAddress", address.checkUserLogin);
router.post("/updateAddress", address.updateAddress);
router.post("/deleteAddress", address.checkUserLogin);
router.post("/deleteAddress", address.deleteAddress);
router.get("/queryAddress", address.checkUserLogin);
router.get("/queryAddress", address.queryAddress);
router.get("/queryAddressTree", address.checkUserLogin);
router.get("/queryAddressTree", address.queryAddressTree);

// shopping cart router list
router.post("/addCart", shoppcart.checkUserLogin);
router.post("/addCart", shoppcart.addCart);
router.post("/updateCart", shoppcart.checkUserLogin);
router.post("/updateCart", shoppcart.updateCart);
router.get("/deleteCart", shoppcart.checkUserLogin);
router.get("/deleteCart", shoppcart.deleteCart);
router.get("/queryCart", shoppcart.checkUserLogin);
router.get("/queryCart", shoppcart.queryCart);
router.get("/queryCartPaging", shoppcart.checkUserLogin);
router.get("/queryCartPaging", shoppcart.queryCartPaging);

// employee router list
router.get("/checkRootLogin", employee.checkRootLogin);
router.post("/employeeLogin", employee.employeeLogin);
router.get("/employeeLogout", employee.employeeLogout);

module.exports = router;